import React, {Component} from 'react';
import ReactDom from 'react-dom';
import { FormattedMessage, injectIntl } from 'react-intl';
import {actions} from "mirrorx";
import {FormControl, Button, Modal, Message} from "tinper-bee";
import Radio from 'bee-radio';
import moment from 'moment'
import DatePicker from "bee-datepicker";
import FormError from 'components/FormError';
import RefComponent from 'components/RefComponent';
import FormList from 'components/FormList'

let {RangePicker} = DatePicker;

import './index.less'

const FormItem = FormList.Item;

class CreateDisable extends Component {
    constructor(props) {
        super(props);
        this.state = {
        }

    }
    

    CreateDisable = (delFlag) => {
        let { selectData } = this.props;
    
        if (delFlag) {
            this.props.form.validateFields((err, _values) => {
                
                if(err) {
                    Message.create({ content: '请输入值', color: 'warning' });
                }else {
                    let ids = [];
                    selectData.map(item=>{
                        ids.push(item.id);
                    })
                    ids = ids.join(',');
                    let param = {
                        data: {
                            ids:ids,
                            result:_values.stopCause
                        },
                        header: {
                            url: `occ-fee/fee/activity-scheme/batch-disable`,
                            method: "post",
                            ContentType: 'application/x-www-form-urlencoded;charset=utf-8',
                        }
                    }
                    actions.ActivityProgram.ButtonSetsModel(param);
                    this.props.closeCreateDisableModal();
                }
                
            })

            
            
        }else {
            this.props.closeCreateDisableModal();
        }
        

    }


    render() {
        let {form,onCallback,showCreateDisableModal} = this.props;
        let { getFieldProps, getFieldError } = this.props.form;

        let self = this;
        return (
            <Modal
            show={showCreateDisableModal}
            onHide={this.CreateDisable} >
            <Modal.Header>
                <Modal.Title>停用</Modal.Title>
            </Modal.Header>

            <Modal.Body>
                <FormItem 
                    required={true}
                    label={'停用原因'}
                >
                        <FormControl
                            key={`stopCause`}
                            {...getFieldProps(`stopCause`, {
                                rules: [
                                    {
                                        required: true,
                                        message: "请输入",
                                    }
                                ],
                            })}
                        />

                </FormItem>
            </Modal.Body>

            <Modal.Footer>
                <Button onClick={() => this.CreateDisable(false)} style={{ marginRight: 10 }}><FormattedMessage id="js.Ref.Ref224.0012" defaultMessage="关闭" /></Button>
                <Button onClick={() => this.CreateDisable(true)} ><FormattedMessage id="js.com.Pas.0005" defaultMessage="确定" /></Button>
            </Modal.Footer>
        </Modal>

        )
    }
}

export default FormList.createForm()(injectIntl(CreateDisable))
